//
//  YCVCsSegueTransition.m
//  DemoTransition
//
//  Created by yunsheng on 15/7/23.
//  Copyright (c) 2015年 yunsheng. All rights reserved.
//

#import "YCVCsWindTransition.h"

@implementation YCVCsWindTransition

-(void)perform
{
    UIView *fromVCView = ((UIViewController *)self.sourceViewController).view;
    UIView *toVCView = ((UIViewController *)self.destinationViewController).view;
    
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    
    toVCView.frame = CGRectMake(0, screenHeight, screenWidth, screenHeight);
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window insertSubview:toVCView aboveSubview:fromVCView];
    
    [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
        toVCView.frame = CGRectOffset(toVCView.frame, 0.0, -screenHeight);
    } completion:^(BOOL finished) {
        [self.sourceViewController presentViewController:self.destinationViewController animated:NO completion:nil];
    }];
}

@end
